package com.example.project.controller;

import com.example.project.aop.AuthLogin;
import com.example.project.aop.ResponseResult;
import com.example.project.enums.RoleEnum;
import com.example.project.service.FileService;
import com.example.project.vo.model.FileVo;
import com.example.project.vo.model.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("/file-manger")
public class FileMangerController {

    @Resource
    private FileService fileService;

    @ApiOperation("下载单个文件")
    @GetMapping("/down-one")
    public void downOne(String path, HttpServletResponse response) throws IOException {
        fileService.downOne(path,response);
    }

    @ApiOperation("打包下载合同文件")
    @GetMapping("/down-press-one")
    public void downPressOne(Long id,Integer type, HttpServletResponse response){
        fileService.downPressOne(id,type,response);
    }


    @ApiOperation("上传文件")
    @PostMapping("/upload")
    public Result<?> upload( FileVo fileVo){
        fileService.upload(fileVo);
        return Result.success("上传成功！");
    }



}
